a5_scaleImageFileUsingImageMagic Function

Syntax

C a5_scaleImageFileUsingImageMagic(C imageFileNameIn ,C imageFileNameOut ,C scaleCommand [,L flagExecuteCommand ])

Arguments

imageFileNameInCharacter

The filename for the image to scale.

imageFileNameOutCharacter

The filename to save the scaled image as.

scaleCommandCharacter

A comma-delimited string specifying how to scale the image. The command can specify a ratio (e.g. "ratio=0.5") or an explicit image size. The string can contain the following options. Use the a5wcb_scaleImagePrompt() function to generate the command for you:

option
Description
ratio

A decimal value defining the scale ratio. E.g. "ratio=0.5" to scale image to 50% it's size. "ratio=2.0" to make the image twice a big.

method

Defines the scaling method to use. Can be "Proportional" (aspect ratio is preserved) or "Independent" (aspect ratio is ignored.) method is required if the image is explicitly resized using width and/or height.

units

Defines the units for the maxSize, width, and height options. Required if the image will be explicitly resized to a defined width and/or height.

maxSize

The max length of the width or height of the image. If maxSize is specified, you must also define units and appliesTo.

appliesTo

Defines the dimension the defined maxSize applies to. Can be "width", "height", or "max" (the maxSize is applied to the longer of the two dimensions of the image.) E.g. "method=proportional,units=inches,maxSize=2.5,appliesTo=height" (image max height is 2.5 inches), "method=proportional,units=pixels,maxSize=400,appliesTo=max" (the longest edge of the image - width or height - has a maximum size of 400 pixels)

width

Resize the image to the specified width. Width is a number representing the width of the image in units. E.g. "method=proportional,units=pixels,width=800" (800 pixels), "method=proportional,units=inches,width=3.5" (3.5 inches)

height

Resize the image to the specified height. Height is a number representing the height of the image in units. E.g. "method=proportional,units=pixels,height=400" (400 pixels), "method=proportional,units=inches,height=2.25" (2.25 inches)

flagExecuteCommandLogical

Default = .T.. If .T., the image will be scaled. Otherwise, the image will not be scaled.

Returns

resultCharacter

Returns the command send to the a5_runImageMagicCommand() function to scale the image.

Description

Scales an image file using ImageMagick. The scaleCommand is created using this function: a5wcb_scaleImagePrompt("")

Example

dim fileIn as c = "C:\temp\img.jpg"
dim fileOut as c = "C:\temp\img_scaled.jpg"
dim cmd as c = "method=proportional,units=pixels,maxSize=533,appliesTo=width"
'cmd =  "ratio=2"

? a5_scaleImageFileUsingImageMagic(fileIn,fileOut,cmd)
= "-resize 533"